package pais.db;

import java.io.IOException;

import papos.rowset.AdvRandomAccessFile;
import papos.rowset.KeyDesc;
import papos.rowset.Storable;


public class PAISSystem implements Storable {
  /* fields should be public in order to be stored in StorageSystem */  
  public int    systemID_; // primary key for PAISSystem record.
  public long   nextUID_;  // url id     ; primary key value for HtmlPage 
  public long   nextKID_;  // keyword id ; primary key value for Keyword

  public PAISSystem() {
  }
  public PAISSystem(int systemID, long nextUID, long nextKID ) {
    systemID_ = systemID;
    nextUID_ = nextUID;
    nextKID_ = nextKID;
  }
  public KeyDesc[] getKeyDesc() {
    return new KeyDesc[] { 
        new KeyDesc("systemID_", false),
        new KeyDesc("nextUID_", false),
        new KeyDesc("nextKID_", false)
    };	
  }
  public int maxSize() {
    return 4 + 8 + 8;
  }
  public Object clone() {
    return new PAISSystem( systemID_, nextUID_, nextKID_ );
  }
  public void writeObject(AdvRandomAccessFile raf) throws IOException {
    raf.writeInt(systemID_);
    raf.writeLong(nextUID_);
    raf.writeLong(nextKID_);
  }
  public void readObject(AdvRandomAccessFile raf) throws IOException, ClassNotFoundException {
    systemID_ = raf.readInt();
    nextUID_ = raf.readLong();
    nextKID_ = raf.readLong();
  }
  public long getNextUID() {
    return nextUID_;
  }
  public void setNextUID(long nextUID) {
    this.nextUID_ = nextUID;
  }
  public long getNextKID() {
    return nextKID_;
  }
  public void setNextKID(long nextKID) {
    this.nextKID_ = nextKID;
  }
  public void setSystemID(int systemID) {
    this.systemID_ = systemID;
  }
}
